#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<string>
using namespace std;
class Solution
{
public:
    string sortSentence(string s)
    {
        string ret;
        int n = 0;
        for (auto& ch : s)
        {
            if (ch == ' ') n++;
        }
        vector<string> arr(n + 2);
        string tem;
        for (auto& ch : s)
        {
            if (isalpha(ch)) tem += ch;
            if (isdigit(ch))
            {
                arr[ch - '0'] = tem;
                tem.clear();
            }
        }
        for (int i = 1; i < n + 2; i++)
        {
            ret += arr[i];
            if (i < n + 1)
                ret += " ";
        }
        return ret;

    }
};
int main()
{
    string s = "is2 sentence4 This1 a3";
    Solution().sortSentence(s);
    return 0;
}